Skip Ribbon Commands
Skip to main content

How do I create a formatting rule that relies on several fields?

Background: You can map each placeholder in a document template to a field in ContactsLaw. Formatting rules allow you to transform the value of the field before it is inserted into the document. They are designed to operate independently of each other and only draw upon the information that comes from the field.
 
A situation may arise where you need to create a formatting rule that relies on several fields. For example, if you want to insert a tick if a contact has both an associated entity and an industry, or if you want to insert the contact's first name only if they have a street address. To achieve this, you will need to combine two concepts; composite fields and simple formulas:
  1. Create a composite mapping (e.g. by dragging-and-dropping while holding the Shift key or using the table editor) which contains all of the fields that you want to examine or insert into the placeholder in the template.

    multi-var-1.png


  2. Open the formatting rules and, to each field that makes up the mapping, add the 'Assign to a variable' rule. Select an appropriate name for each variable (however, do not use 'x' as this is reserved for the field as a whole).

    multi-var-2.png


  3. In the 'Normal rules' section, add the 'Evaluate a formula' rule. You will need to write a formula which is expressed in terms of the variables you declared in the previous step. Be sure to specify what the output (if any) should be for each possibility you want to test for.

    multi-var-3.png


  4. Test your rule by entering/editing the values in the example grid and verify that the inputs produce the expected output.

    multi-var-4.png

In the above approach, assigning the individual field values to variables removes them from the output and allows them to be referenced in the formula. The formula then determines what is inserted into the placeholder in the template. You can combine this technique with other formatting rules to exercise greater control over the values going into (or coming out of) the formula.